package com.lh.disruptor.handler;

import com.lh.disruptor.Event;
import com.lmax.disruptor.EventHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author: linghao
 * @since: 2025/5/24
 */
@Slf4j
public abstract class AbstractEventHandler implements EventHandler<Event> {

    @Override
    public void onEvent(Event event, long l, boolean b) throws Exception {
        if(this.check(event)){
            this.excuteBefore(event);
            this.excute(event);
            this.excuteAfter(event);
        }
    }


    public abstract void excute(Event event);

    public void excuteBefore(Event event) {
        log.info("excuteBefore");
    }
    public void excuteAfter(Event event){
        log.info("excuteAfter");
    }

    public boolean check(Event event) {
        return true;
    }
}
